#include<bits/stdc++.h>
using namespace std;

int n;
int u,v;
int fa[105];
vector<int> e[105];
int hei=0,wid=0;
int h[105],w[105];
bool visit[105];

int main(){
	cin>>n;
	fa[1]=1;
	for(int i=0;i<n-1;i++){
		cin>>u>>v;
		fa[v]=u;
		e[u].push_back(v);
	}
	memset(h,0,sizeof(h));
	memset(w,0,sizeof(w));
	h[1]=1;	
	w[1]=1;
	queue<int> que;
	que.push(1);
	while(!que.empty()){
		u=que.front();
		que.pop();
		for(auto& v:e[u]){
			h[v]=h[u]+1;
			hei=max(hei,h[v]);
			w[hei]++;
			wid=max(w[hei],wid);
			que.push(v);
		}
	};
	cout<<hei<<endl;
	cout<<wid<<endl;
	//
	cin>>u>>v;
	memset(visit,false,sizeof(visit));
	int j=u,k=v;		
	int ans=0; 
	while(true){
		if(visit[j]){
			ans=2*(h[u]-h[j])+h[v]-h[j];
			break;
		}
		if(visit[k]){
			ans=2*(h[u]-h[k])+h[v]-h[k];
			break;
		}
		visit[j]=true;
		visit[k]=true;
		j=fa[j];
		k=fa[k];
	}
	cout<<ans;
	return 0;
}
